package finaldemo;

class Person {
    private String name;
    private int age;

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}

public class Test {

    public static void changeName(final Person p) {
        p.setName("岳飞"); //对象的属性可以改变

        //p = new Person("岳飞",60);//编译错误，对象不能改变
    }

    public static void main(String[] args) {
        final int num = 100;

        //System.out.println(num++); //编译错误，num不能修改

        Person p = new Person("张飞", 30);

        changeName(p);

        System.out.println(p);
    }
}
